<?php
function article_ArticleFull(){
    $tpl = XTemplate::getInstance();
    $template = "full.html";
    $tpl->assign_file('CONTENT',$template);
    if(getCurrentRequestParameters('id') < 1){
        redirectToUrl('/cabinet-psihologie-psihoterapie-articole/');
    }
    $contentMapper = new article_Mapper();
    $obj = $contentMapper->findById(getCurrentRequestParameters('id'));
    if(!$obj){
        redirectToUrl('/cabinet-psihologie-psihoterapie-articole/');
    }

   $tpl->assign('title', $obj->getTitle());
   $tpl->assign('addData', $obj->getAddData());
   $tpl->assign('body', $obj->getBody());
   $tpl->assign('back_link', '<a href="/cabinet-psihologie-psihoterapie-articole/">Vezi toate articolele</a>');
   $tpl->parse('main.back_link');
   $tpl->parse('main.module_title', $obj->getBody());
    $tpl->assign('metaTitle', $obj->getTitle().",");
    $tpl->assign('metaKeywords', $obj->getKeywords() );
    $tpl->assign('metaDescription', $obj->getTeaser() );
    $tpl->parse('main.metaTitle');
    $tpl->parse('main.metaKeywords');
    $tpl->parse('main.metaDescription');    
 
     
}
function article_Default(){
    //    
    $query = "SELECT * FROM `article` ORDER BY articleAddDate  DESC, articleId DESC ";
    $PDO = DB_LINK::getInstance();
    $stm = $PDO->prepare($query);
    $stm->execute();
    $raw = $stm->fetchAll();
    $stm->closeCursor();
    $contentMapper = new article_Mapper();
    $collection = new article_Mapper_Collection($raw, $contentMapper);
    
    $tpl = XTemplate::getInstance();    
    $template = "listing.html";
    $tpl->assign_file('CONTENT',$template);

    foreach ($collection as $obj){        
        $teaser = strip_tags($obj->getBody());
        $teaser = substr($teaser, 0, 200)."...";
        $tpl->assign('teaser', $teaser);
        $tpl->assign('title', $obj->getLink(array()));
        $tpl->assign('addData', $obj->getAddData());
        $tpl->assign('link', $obj->getLink(
                array('text' => 'mai mult')
        ));
        
        $tpl->parse('main.row');
    }
    
    $tpl->assign('moduleTitle', 'Articole psihologie');

    $tpl->assign('metaTitle', 'Articole psihologie');
    $tpl->assign('metaKeywords', 'articole, psihologie, psiholog' );
    $tpl->assign('metaDescription', 'articole psihologie si psihoterapie' );
    $tpl->parse('main.metaTitle');
    $tpl->parse('main.metaKeywords');
    $tpl->parse('main.metaDescription');
    $tpl->parse('main.module_title');

}
?>
